<template>
  <div>
    <el-table :data="data" border height="400" :highlight-current-row="true" size="mini">
      <el-table-column type="index" width="50" label="序号" />
      <el-table-column property="createTime" label="时间" />
      <el-table-column property="status" label="处理" />
      <el-table-column property="comment" label="备注" />
    </el-table>
  </div>
</template>
<script>
import { histories } from '@neu/dcam-ui/api/inventoryDuty'

export default {
  name: 'InventoryDutyHistory',
  props: {
    dutyId: {
      required: true,
      type: Number || String,
      default: ''
    }
  },
  data() {
    return {
      data: []
    }
  },
  watch: {
    dutyId: {
      handler(newVal, oldVal) {
        this.fetch()
      },
      immediate: true
    }
  },
  created() {
  },
  methods: {
    fetch() {
      histories(this.dutyId).then(res => {
        this.data = res.data.map(it => {
          let status = ''
          if (it.status === 0) {
            status = '任务下发'
          } else if (it.status === 1) {
            status = '任务提交'
          } else if (it.status === 2) {
            status = '任务驳回'
          } else if (it.status === 3) {
            status = '任务完成'
          }
          it.status = status
          return it
        })
      })
    }
  }
}
</script>
